package edu.zut.main.thread;

public class ThreadDemo5 {
    public static void main(String[] args) {

        //线程的礼让
        ThreadYield threadYield = new ThreadYield();
        new Thread(threadYield,"线程A").start();
        new Thread(threadYield,"线程B").start();
        new Thread(threadYield,"线程C").start();

    }
}
class ThreadYield implements Runnable{

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName() + " begin...");
        //礼让  线程的礼让   当前线程会由运行转为暂停（就绪）
        Thread.yield();
        System.out.println(Thread.currentThread().getName() + " stop...");
    }
}
